'''
Created on Dec 13, 2011

@author: facundo
'''

from program import Program
from instruction import Instruction
from factoryKernel import FactoryKernel
from managerFactory import ManagerFactory
from disc import Disc

def main():
    n1 = 'A.c';
    n2 = 'B.c';
    n3 = 'C.c';
    n4 = 'D.c';
    
    prog = Program([Instruction('CPU', n1),Instruction('CPU', n1),Instruction('IO', n1), Instruction('CPU', n1), Instruction('END', n1)], n1, 1)
    prog1 = Program([Instruction('CPU', n2), Instruction('IO', n2), Instruction('IO', n2), Instruction('CPU', n2), Instruction('END', n2)], n2, 6)
    prog2 = Program([Instruction('CPU', n3),Instruction('IO', n3), Instruction('CPU', n3), Instruction('IO', n3),Instruction('IO', n3), Instruction('CPU', n3), Instruction('END', n3)], n3, 2)
    prog3 = Program([Instruction('CPU', n4),Instruction('CPU', n4), Instruction('CPU', n4), Instruction('IO', n4),Instruction('IO', n4), Instruction('CPU', n4), Instruction('CPU', n4), Instruction('CPU', n4), Instruction('END', n4)], n4, 3)
   
    hdd = Disc()
    
    hdd.load(prog.name, prog)
    hdd.load(prog2.name, prog2)
    hdd.load(prog3.name, prog3)
    hdd.load(prog1.name, prog1)
   
    mmu = ManagerFactory().memoryManagerPaging(hdd, 2, 10)
    kernel1 = FactoryKernel().KernelWithPriority(mmu)
    kernel1.start()
    kernel1.run(hdd.read(prog.name))
    kernel1.run(hdd.read(prog2.name))
    kernel1.run(hdd.read(prog3.name))
    kernel1.run(hdd.read(prog1.name))
    
if __name__ == "__main__":
    main()